package com.qf.adminService.impl;

import com.qf.adminDao.AdminOrderDao;
import com.qf.adminDao.AdminUserDao;
import com.qf.adminService.AdminOrderService;
import com.qf.dao.UserDao;
import com.qf.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bss
 * @version V1.0
 * @Project maven
 * @Package com.qf.adminService.impl
 * @Description:
 * @Date 2022/10/4 20:41
 */
@Service
public class AdminOrderServiceImpl implements AdminOrderService {

    @Autowired
    AdminOrderDao adminOrderDao;
    @Autowired
    UserDao userDao;

    @Override
    public List<Order> getAllOrder() {
        List<Order> allOrder = adminOrderDao.getAllOrder();
        for (Order order : allOrder) {
            order.setUsername(userDao.findById(order.getUid()).getUsername());
        }
        return allOrder;
    }

    @Override
    public List<Order> selectOrder(String  uid, String status) {
        List<Order> list = adminOrderDao.selectOrder(uid,status);
        for (Order order : list) {
            order.setUsername(userDao.findById(order.getUid()).getUsername());
        }
        return list;
    }

    @Override
    public void sendOrder(String oid) {
        adminOrderDao.sendOrder(oid);
    }
}
